<template>
  <div>
    <div class="Logout">
      <Logout>退出</Logout>
    </div>
    <h1>查询教师信息</h1>
    <el-form>
      <el-button @click="count" type="success" icon="el-icon-search">点击查询教师数量</el-button>
    </el-form>
    <el-table  v-if="tableData"
               :data="tableData"
               border
               style="width: 100%">
      <template slot="empty" >
        <span style="font-size: 20px"></span>
      </template>
      <el-table-column
        prop="tno"
        label="教师编号"
        width="120">
      </el-table-column>
      <el-table-column
        prop="tname"
        label="教师姓名"
        width="120">
      </el-table-column>
      <el-table-column
        prop="tlevel"
        label="教师等级"
        width="120">
      </el-table-column>
      <el-table-column
        prop="tcharacter"
        label="教师特长"
        width="120">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import Logout from "./Logout";
export default {
  name: "FindTeacher",
  components:{Logout},
  created() {
    let  _this = this;
    console.log("即将打印全体教师")
    this.$axios.post(`/ShowTeacher`).then((res) => {
      console.log(res.data);
      this.tableData = res.data;
      this.sta = true
      console.log("全部数据：", this.tableData)
    })
  },
  methods:{
    count() {
      this.$axios.post(`/CountTeacher`).then((res) => {
        console.log(res.data);
        this.counts = res.data;
        console.log("教师数量：", this.counts);
        if (res.data.msg=="返回教师数量成功") {
          alert("教师数量：" + res.data.data)
        }
      })
    }
  },

  data () {
    return {
      user:{
        tno:this.search_tno,
        tname:'',
        tlevel:'',
        tcharacter:'',
      },
      sta:false,
      search_tno:'',
      tableData: null,
      counts:'',
    }
  }
}
</script>

<style scoped>

</style>
